﻿<html>
<head>
<title>JSFlow Logging Tests</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<script type="text/javascript" src="../../html/html.js"></script>
<script type="text/javascript" src="../jsflow.js"></script>
<script type="text/javascript" src="testingLog.js"></script>
<script type="text/javascript">
function $(id){return document.getElementById(id);}

var log1 = new TestingLog();
log1.expectations = [
	"Sequence 1 begins",
	"Function 1.1 begins",
	"Function 1.1 ended",
	"Function 1.2 begins",
	"Function 1.2 ended",
	"Function 1.3 begins",
	"Function 1.3 ended",
	"Parallel 1.4 begins",
	"Function 1.4.1 begins",
	"Function 1.4.2 begins",
	"Function 1.4.3 begins",
	"Sequence 1.4.4 begins",
	"Function 1.4.4.1 begins",
	"Function 1.4.4.1 ended",
	"Function 1.4.4.2 begins",
	"Function 1.4.3 ended",
	"Function 1.4.4.2 ended",
	"Sequence 1.4.4 ended",
	"Function 1.4.1 ended",
	"Function 1.4.2 ended",
	"Parallel 1.4 ended",
	"Function 1.5 begins",
	"Function 1.5 ended",
	"Function 1.6 begins",
	"Function 1.6 ended",
	"Function 1.7 begins",
	"Function 1.7 ended",
	"Sequence 1 ended"
];

function test1(){with(JSFlow){
	var process = sequence(
		function(){(new Continuation())()},
		function(){(new Continuation())()},
		function(){(new Continuation())()},
		parallel(
			function(){
				var go = new Continuation();
				setTimeout(function(){
					go();
				}, 500);
			},
			function(){
				var go = new Continuation();
				setTimeout(function(){
					go();
				}, 2000);
			},
			function(){
				var go = new Continuation();
				setTimeout(function(){
					go();
				}, 200);
			},
			sequence(
				function(){
					var go = new Continuation();
					setTimeout(function(){
						go();
					}, 150);
				},
				function(){
					var go = new Continuation();
					setTimeout(function(){
						go();
					}, 100);
				}
			)
		),
		function(){
			var go = new Continuation();
			go();
		},
		function(){
			var go = new Continuation();
			go();
		},
		function(){
			var go = new Continuation();
			go();
			$("out").innerHTML = log1.render();
		}
	);
	
	log1.connect(process);
	$("out").innerHTML = Html.img({src:"../waitcircle.gif"});
	process.run();
	
	
}}

function init(){
	$("versionPanel").innerHTML = JSFlow.version;
	test1();
}
</script>
</head>
<body onload="init()">
	<h1>JSFlow Logging Tests</h1>
	<p>JSFlow v.<span id="versionPanel"></span></p>
	<div id="testContainer" style="display:none;"></div>
	<div id="out"></div>
</body>
</html>